home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / sharutil.2 / sharutil / sharutils-4.2 / contrib / uudecode.pl < prev    next >
Encoding:
Text File  |  1995-03-08  |  522 b   |  25 lines

  1. # uuencode in Perl.
  2. # Copyright (C) 1995 Free Software Foundation, Inc.
  3. # Franτois Pinard <pinard@iro.umontreal.ca>, 1995.
  4.  
  5. # `perl uudecode.pl FILES' will decode all uuencoded files found in
  6. # all input FILES, stripping headers and other non uuencoded data.
  7.  
  8. while (<>)
  9. {
  10.     if (/^begin [0-7][0-7][0-7] ([^\n ]+)$/)
  11.     {
  12.     open (OUTPUT, ">$1") || die "Cannot create $1\n";
  13.     binmode OUTPUT;
  14.     while (<>)
  15.     {
  16.         last if /^end$/;
  17.         $block = unpack ("u", $_);
  18.         print OUTPUT $block;
  19.     }
  20.     close OUTPUT;
  21.     }
  22. }
  23.  
  24. exit 0;
  25.